import Vue from 'vue'
import VueRouter from 'vue-router'
import layout from '@/views/layout.vue'
import Home from '@/views/home.vue'

import Login from '@/views/login.vue'
import Register from '@/views/register.vue'

const List = () => import('@/views/list.vue')
const News = () => import('@/views/news.vue')
const Profile = () => import('@/views/profile.vue')
const City = () => import('@/views/city.vue')
const Map = () => import('@/views/map.vue')
const Detail = () => import('@/views/detail.vue')

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: layout,
    redirect: '/home',
    children: [
      { path: '/home', component: Home },
      { path: '/list', component: List },
      { path: '/news', component: News },
      { path: '/profile', component: Profile }
    ]
  },
  { path: '/login', component: Login },
  { path: '/register', component: Register },
  { path: '/city', component: City },
  { path: '/map', component: Map },
  { path: '/detail', component: Detail }
]

const router = new VueRouter({
  routes
})

export default router
